/*
This file is part of SmartShopper

SmartShopper is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

SmartShopper is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with vlc-remote.  If not, see <http://www.gnu.org/licenses/>.
*/

import QtQuick 1.1
import com.meego 1.0

Page {
    id: mainPage
    property string helpText: "Help page for Main"
//    ListsPage{id: listsPage}
//    ShopsPage{id: shopsPage}
//    TrackPage{id: trackPage}

    function openFile(file) {
        var component = Qt.createComponent(file)

        if (component.status == Component.Ready)
            pageStack.push(component);
        else
            console.log("Error loading component:", component.errorString());
    }

    tools: ToolBarLayout {
            visible: true
            smooth: true

            ToolIcon {
                id: iconHelp
                iconSource: "icons/user-guide.png"
                onClicked: { myMenu.close(); pageStack.push(helpPage, {displayedText: pageStack.currentPage.helpText}) }
                anchors.centerIn: parent
                visible: true
            }

            ToolIcon {
                platformIconId: "toolbar-view-menu";
                anchors.right: parent === undefined ? undefined : parent.right
                onClicked: (myMenu.status == DialogStatus.Closed) ? myMenu.open() : myMenu.close()
            }
    }

    Button{
        id: buttonLists
        anchors.bottom: buttonShops.top
        anchors.bottomMargin: 10
        anchors.left: buttonShops.left
        anchors.leftMargin: 0
        text: qsTr("Lists")
        onClicked: { myMenu.close();
            //pageStack.push(listsPage);
            mainPage.openFile("ListsPage.qml");
        }
        width: parent.width - parent.width/10
        height: parent.height / 5
    }
    Button{
        id: buttonShops
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.centerIn: parent
//        anchors.topMargin: 10
        text: qsTr("Shops")
//        onClicked: { myMenu.close(); pageStack.push(shopsPage); }
        onClicked: { myMenu.close();
            //pageStack.push(listsPage);
            mainPage.openFile("ShopsPage.qml");
        }
        width: parent.width - parent.width/10
        height: parent.height / 5
    }
    Button{
        id: buttonTrack
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: buttonShops.bottom
        anchors.topMargin: 10
        text: qsTr("Tracks")
//        onClicked: { myMenu.close(); pageStack.push(trackPage); }
        onClicked: { myMenu.close();
            //pageStack.push(listsPage);
            mainPage.openFile("TrackPage.qml");
        }
        width: parent.width - parent.width/10
        height: parent.height / 5
    }
}
